<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>{{ code.title }} - Creeps</title>
        <style>
            * {
                box-sizing: border-box;
            }

            body {
                font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
                max-width: 1200px;
                margin: 0 auto;
                padding: 20px;
                background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
                min-height: 100vh;
                position: relative;
            }

            body::before {
                content: '';
                position: fixed;
                top: 0;
                left: 0;
                width: 100%;
                height: 100%;
                background: radial-gradient(circle at 20% 80%, rgba(0, 212, 255, 0.1) 0%, transparent 50%),
                    radial-gradient(circle at 80% 20%, rgba(100, 150, 255, 0.1) 0%, transparent 50%),
                    radial-gradient(circle at 40% 40%, rgba(255, 255, 255, 0.05) 0%, transparent 50%);
                pointer-events: none;
                z-index: -1;
            }

            .container {
                background: linear-gradient(135deg, rgba(45, 55, 85, 0.3) 0%, rgba(35, 45, 75, 0.4) 100%);
                backdrop-filter: blur(15px);
                padding: 40px;
                border-radius: 20px;
                box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), 0 0 20px rgba(100, 150, 255, 0.2),
                    inset 0 0 15px rgba(255, 255, 255, 0.05);
                border: 2px solid;
                border-image: linear-gradient(135deg, rgba(255, 255, 255, 0.4), rgba(100, 150, 255, 0.6)) 1;
                color: rgba(255, 255, 255, 0.9);
            }

            .header {
                display: flex;
                justify-content: space-between;
                align-items: center;
                margin-bottom: 30px;
                padding-bottom: 20px;
                border-bottom: 2px solid;
                border-image: linear-gradient(135deg, rgba(255, 255, 255, 0.3), rgba(100, 150, 255, 0.5)) 1;
            }

            .header h1 {
                margin: 0;
                background: linear-gradient(135deg, #00d4ff, #6496ff, #ffffff);
                -webkit-background-clip: text;
                -webkit-text-fill-color: transparent;
                background-clip: text;
                font-size: 2.5rem;
                font-weight: 700;
                text-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
                filter: drop-shadow(0 0 8px rgba(0, 212, 255, 0.3));
            }
            .btn {
                display: inline-block;
                padding: 12px 24px;
                background: linear-gradient(135deg, rgba(100, 150, 255, 0.8), rgba(0, 212, 255, 0.8));
                color: white;
                text-decoration: none;
                border-radius: 25px;
                font-weight: 600;
                font-size: 0.95rem;
                transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
                margin-left: 15px;
                border: 2px solid rgba(255, 255, 255, 0.3);
                backdrop-filter: blur(10px);
                position: relative;
                overflow: hidden;
                text-transform: uppercase;
                letter-spacing: 0.5px;
            }

            .btn::before {
                content: '';
                position: absolute;
                top: 0;
                left: -100%;
                width: 100%;
                height: 100%;
                background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
                transition: left 0.5s ease;
            }

            .btn:hover {
                background: linear-gradient(135deg, rgba(100, 150, 255, 1), rgba(0, 212, 255, 1));
                border-color: rgba(255, 255, 255, 0.8);
                transform: perspective(500px) rotateX(5deg) rotateY(5deg) translateZ(10px) translateY(-3px);
                box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3), 0 0 30px rgba(100, 150, 255, 0.4), 0 0 15px rgba(255, 255, 255, 0.2);
                color: white;
                text-decoration: none;
            }

            .btn:hover::before {
                left: 100%;
            }

            .btn-danger {
                background: linear-gradient(135deg, rgba(220, 53, 69, 0.8), rgba(255, 100, 100, 0.8));
            }

            .btn-danger:hover {
                background: linear-gradient(135deg, rgba(220, 53, 69, 1), rgba(255, 100, 100, 1));
                box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3), 0 0 30px rgba(220, 53, 69, 0.4), 0 0 15px rgba(255, 255, 255, 0.2);
            }
            .code-meta {
                display: flex;
                flex-wrap: wrap;
                gap: 25px;
                margin-bottom: 30px;
                color: rgba(255, 255, 255, 0.8);
            }

            .code-meta-item {
                display: flex;
                align-items: center;
                background: rgba(255, 255, 255, 0.1);
                padding: 12px 18px;
                border-radius: 15px;
                backdrop-filter: blur(5px);
                border: 1px solid rgba(255, 255, 255, 0.2);
            }

            .code-meta-label {
                font-weight: 700;
                margin-right: 8px;
                color: rgba(100, 150, 255, 0.9);
            }
            .code-description {
                margin-bottom: 35px;
                padding: 25px;
                background: linear-gradient(135deg, rgba(100, 150, 255, 0.1), rgba(0, 212, 255, 0.1));
                border-radius: 15px;
                border-left: 4px solid rgba(100, 150, 255, 0.8);
                backdrop-filter: blur(10px);
                border: 1px solid rgba(255, 255, 255, 0.2);
                color: rgba(255, 255, 255, 0.9);
                line-height: 1.6;
            }
            .code-content {
                margin-top: 30px;
            }

            .code-content h2 {
                margin-bottom: 20px;
                padding-bottom: 15px;
                border-bottom: 2px solid;
                border-image: linear-gradient(135deg, rgba(255, 255, 255, 0.3), rgba(100, 150, 255, 0.5)) 1;
                background: linear-gradient(135deg, #00d4ff, #6496ff);
                -webkit-background-clip: text;
                -webkit-text-fill-color: transparent;
                background-clip: text;
                font-size: 1.8rem;
                font-weight: 600;
            }

            pre {
                background: linear-gradient(135deg, rgba(45, 55, 85, 0.4), rgba(35, 45, 75, 0.5));
                color: #abb2bf;
                padding: 25px;
                border-radius: 15px;
                overflow-x: auto;
                font-family: 'Fira Code', 'Courier New', Courier, monospace;
                line-height: 1.6;
                border: 2px solid rgba(255, 255, 255, 0.1);
                backdrop-filter: blur(10px);
                box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3), inset 0 0 15px rgba(255, 255, 255, 0.05);
            }
            .version-list {
                margin-top: 50px;
            }

            .version-list h2 {
                margin-bottom: 25px;
                padding-bottom: 15px;
                border-bottom: 2px solid;
                border-image: linear-gradient(135deg, rgba(255, 255, 255, 0.3), rgba(100, 150, 255, 0.5)) 1;
                background: linear-gradient(135deg, #00d4ff, #6496ff);
                -webkit-background-clip: text;
                -webkit-text-fill-color: transparent;
                background-clip: text;
                font-size: 1.8rem;
                font-weight: 600;
            }

            .version-item {
                padding: 25px;
                margin-bottom: 20px;
                border: 2px solid rgba(255, 255, 255, 0.2);
                border-radius: 15px;
                background: linear-gradient(135deg, rgba(45, 55, 85, 0.3), rgba(35, 45, 75, 0.4));
                backdrop-filter: blur(10px);
                transition: all 0.3s ease;
            }

            .version-item:hover {
                border-color: rgba(100, 150, 255, 0.5);
                box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3), 0 0 20px rgba(100, 150, 255, 0.2);
                transform: translateY(-3px);
            }

            .version-header {
                display: flex;
                justify-content: space-between;
                align-items: center;
                margin-bottom: 15px;
            }

            .version-title {
                font-weight: 700;
                font-size: 1.2rem;
                color: rgba(100, 150, 255, 0.9);
            }

            .version-meta {
                display: flex;
                justify-content: space-between;
                color: rgba(255, 255, 255, 0.7);
                font-size: 0.95rem;
                margin-bottom: 15px;
            }

            .version-message {
                margin-top: 15px;
                padding: 15px;
                background: rgba(255, 255, 255, 0.1);
                border-radius: 10px;
                font-style: italic;
                color: rgba(255, 255, 255, 0.8);
                border-left: 3px solid rgba(100, 150, 255, 0.6);
            }

            .public-status-control {
                margin: 25px 0;
                text-align: center;
            }

            .btn-toggle-public {
                background: linear-gradient(135deg, rgba(100, 150, 255, 0.8), rgba(0, 212, 255, 0.8));
                border: 2px solid rgba(255, 255, 255, 0.3);
                padding: 12px 25px;
                border-radius: 25px;
                color: white;
                font-weight: 600;
                font-size: 1rem;
                cursor: pointer;
                transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
                backdrop-filter: blur(10px);
                position: relative;
                overflow: hidden;
                text-transform: uppercase;
                letter-spacing: 0.5px;
            }

            .btn-toggle-public::before {
                content: '';
                position: absolute;
                top: 0;
                left: -100%;
                width: 100%;
                height: 100%;
                background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
                transition: left 0.5s ease;
            }

            .btn-toggle-public:hover {
                background: linear-gradient(135deg, rgba(100, 150, 255, 1), rgba(0, 212, 255, 1));
                border-color: rgba(255, 255, 255, 0.8);
                transform: perspective(500px) rotateX(5deg) rotateY(5deg) translateZ(10px) translateY(-3px);
                box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3), 0 0 30px rgba(100, 150, 255, 0.4), 0 0 15px rgba(255, 255, 255, 0.2);
            }

            .btn-toggle-public:hover::before {
                left: 100%;
            }


            .actions {
                display: flex;
                justify-content: flex-end;
                margin-top: 25px;
            }

            .language-badge {
                display: inline-block;
                padding: 8px 15px;
                background: rgba(255, 255, 255, 0.2);
                border-radius: 20px;
                font-size: 0.9rem;
                color: white;
                margin-left: 15px;
                font-weight: 600;
                backdrop-filter: blur(10px);
                border: 1px solid rgba(255, 255, 255, 0.3);
            }

            /* 响应式设计 */
            @media (max-width: 768px) {
                body {
                    padding: 15px;
                }

                .container {
                    padding: 25px;
                }

                .header {
                    flex-direction: column;
                    gap: 20px;
                    text-align: center;
                }

                .header h1 {
                    font-size: 2rem;
                }

                .code-meta {
                    flex-direction: column;
                    gap: 15px;
                }

                .btn {
                    margin: 5px;
                    padding: 10px 20px;
                    font-size: 0.9rem;
                }

                pre {
                    padding: 20px;
                    font-size: 0.9rem;
                }
            }
        </style>
    </head>
    <body>
        <div class="container">
            <a href="{% url 'codes:code_list' %}" class="nav-link">← 返回代码列表</a>

            <div class="header">
                <h1>{{ code.title }} <span class="language-badge">{{ code.get_language_display }}</span></h1>
                <div>
                    <a href="{% url 'codes:code_update' code.id %}" class="btn">编辑信息</a>
                    <a href="{% url 'codes:code_delete' code.id %}" class="btn btn-danger">删除</a>
                </div>
            </div>

            <div class="code-meta">
                <div class="code-meta-item"><span class="code-meta-label">创建者:</span> {{ code.user.username }}</div>
                <div class="code-meta-item">
                    <span class="code-meta-label">创建时间:</span> {{ code.created_at|date:"Y-m-d H:i" }}
                </div>
                <div class="code-meta-item">
                    <span class="code-meta-label">最后更新:</span> {{ code.updated_at|date:"Y-m-d H:i" }}
                </div>
                <div class="code-meta-item"><span class="code-meta-label">版本数:</span> {{ code.get_version_count }}</div>
            </div>

            {% if code.description %}
            <div class="code-description">{{ code.description|linebreaks }}</div>
            {% endif %} {% if latest_version %}
            <div class="code-content">
                <h2>最新代码 (版本 {{ latest_version.version }})</h2>
                <pre><code>{{ latest_version.content }}</code></pre>

                {% if latest_version.message %}
                <div class="version-message">提交信息: {{ latest_version.message }}</div>
                {% endif %}
            </div>
            {% endif %} {% if versions %}
            <div class="version-list">
                <h2>版本历史</h2>

                {% for version in versions %}
                <div class="version-item">
                    <div class="version-header">
                        <span class="version-title">版本 {{ version.version }}</span>
                        <span>{{ version.created_at|date:"Y-m-d H:i" }}</span>
                    </div>

                    <div class="version-meta">
                        <span>文件大小: {{ version.file_size|filesizeformat }}</span>
                    </div>

                    {% if version.message %}
                    <div class="version-message">{{ version.message }}</div>
                    {% endif %}
                </div>
                {% endfor %}
            </div>
            {% endif %}
        </div>
    </body>
</html>
